package com.ftg.learn.chapter12.springbootdemo.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 布衣
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class R<T> {

    private Integer code;

    private String msg;

    private T data;

    public static <T> R<T> success() {
        return new R<>(200, "success", null);
    }

    public static <T> R<T> success(T t1) {
        return new R<>(200, "success", t1);
    }

    public static <T> R<T> success(String msg,T t1) {
        return new R<>(200, msg, t1);
    }

    public static <T> R<T> build(Integer code, String msg, T t1) {
        return new R<>(code, msg, t1);
    }

    public static <T> R<T> failure() {
        return new R<>(500, "failure", null);
    }

    public static <T> R<T> failure(String s) {
        return new R<>(500, s, null);
    }
}
